<?php if($action == 'c'):?>
    <div class="forum-index">
        <?php $catName =  App::CategorySet()->idToName($id);?>
        <div class="forum-top-link">
            <a href="<?php echo $this->baseurl("/forum/"); ?>"><?php echo $this->__(' Form Page');?></a> &gt;&gt;
            <?php echo $catName;?>
        </div>

        <ul>
            <li class="header-row">
                <div class="title"><?php echo $this->__('Post');?></div>
                <div class="last-post"><?php echo $this->__('Information');?></div>
                <div class="threads">&nbsp;</div>
                <div class="posts"><?php echo $this->__('Posts');?></div>
                <div class="clearboth"></div>
            </li>
            <?php foreach(  $postlist['data'] as $cat):?>
            <li>
                <div class="title">
                    <h2><a href="<?php echo $this->baseurl("/forum/p/{$cat['id']}/" . App::Helper('Utility')->text2normalize($cat['title'])) ?>"><?php echo($cat['title']);?></a></h2>
                    <?php echo substr($cat['description'],0,200); ?>
                    <p><a href="<?php echo $this->baseurl("/forum/p/{$cat['id']}/" . App::Helper('Utility')->text2normalize($cat['title'])) ?>">Read More...</a></p>
                </div>
                <div class="last-post">
                    <br />
                    <?php echo App::Component('appForum')->Helper('Data')->Id2PostInfo($cat['id']); ?>
                </div>
                <div class="threads"><br /> <?php /*<a href="<?php echo $this->baseurl("/forum/p/{$cat['id']}/" . App::Helper('Utility')->text2normalize($cat['title'])) ?>#reply">Reply</a>*/ ?>&nbsp;</div>
                <div class="posts"><br /><?php echo App::Component('appForum')->Helper('Data')->postId2CommentCount($cat['id']); ?></div>
                <div class="clearboth"></div>
            </li>
            <?php endforeach;?>
        </ul>
    </div>
<?php elseif($action == 'p'):?>
    <div class="inner">

        <div class="forum-top-link">
            <?php $catName =  App::CategorySet()->IdToName($postinfo['category']);?>
            <p>
                <a href="<?php echo $this->baseurl("/forum/"); ?>"><?php echo $this->__(' Forum Page');?></a> &gt;&gt;
                <a href="<?php echo $this->baseurl("/forum/c/{$postinfo['category']}/" . App::Helper('Utility')->text2Normalize($catName)); ?>"><?php echo $catName;?></a>
            </p>
        </div>
        <h2 id="post"><?php echo($postinfo['title']);?></h2>
        <ul class="forum-p">
            <li>
                <div class="post-user-info">
                    <?php echo App::Component('appForum')->Helper('Data')->Id2PostInfo($postinfo['id'],false); ?>
                </div>
                <div class="post-info">
                    <?php echo stripslashes(App::Load("Helper/Utility")->codeFormated($postinfo['description'],false));?>
                </div>
            </li>
            <?php if(!empty($commetns['data'])):?>
                    <?php foreach($commetns['data'] as $comment):?>
                       <li>
                            <div class="post-user-info">
                                <?php echo App::Component('appForum')->Helper('Data')->Id2CommentInfo($comment['id'],false); ?>
                            </div>
                            <div class="post-info">
                                <?php echo App::Helper('Utility')->codeFormated($comment['comment'],true);?>
                            </div>
                       </li>
                    <?php endforeach;?>
            <?php endif;?>
        </ul>
        <?php if(App::MemberManager()->AppUserloggedInId()):?>
        <h2 id="reply"><?php echo $this->__('Post a replay'); ?></h2>
        <div style="margin-left:5px">
        <div style="margin-left:5px" class="message"></div>
        <form method="post" class="form forum-comment" action="<?php echo $this->baseurl("/forum/p/{$id}");?>">
            <input type="hidden" name="data[Comment][category]" value="<?php echo $postinfo['category']; ?>" />
            <ul>
                <li><label><?php echo $this->__('Description');?></label><span><?php echo $this->__('HTML is allowed.');?> <textarea name="data[Comment][desc]" rows="10" class="input check_notempty"></textarea></span></li>
                <li><label><?php echo App::Helper('Html')->capachaTag("commentpost",Array("bk_color"=>"#99011E","font_color"=>"#FFFFFF"));?></label><span><input type="text" name="data[Comment][capacha]" class="input check_notempty" longdesc="Please fillin the text display left side image." value="" /></span></li>
                <li><label>&nbsp;</label><span><input type="submit" name="data[Comment][submit]" class="button" value="Submit" /> <a class="anchor" href="#post"><?php echo $this->__('View Post');?></a></span></li>
            </ul>
        </form>
        <?php  App::Helper('JavaScript')->setAjax(array("debug"=>false,"autoHide"=>false))->appForm('.forum-comment');?>
        </div>
        <?php endif;?>
    </div>
<?php else: ?>
    <?php if(App::MemberManager()->AppUserloggedInId()):?>
    <div class="forum-top-link">
        <p>
            <a href="<?php echo $this->baseurl("/add-post-to-forum");?>">New post </a> &nbsp;
            <a href="<?php echo $this->baseurl("/logout");?>">Logout </a>
        </p>
    </div>
    <?php else:?>
    <div class="forum-top-link">
        <p><a href="<?php echo $this->baseurl("/add-post-to-forum");?>">New post </a> &nbsp;
        <a href="<?php echo $this->baseurl("/member-login");?>">Login</a> &nbsp;
        <a href="<?php echo $this->baseurl("/member-signup");?>">Not a member? </a></p>
    </div>
    <?php endif;?>

    <div class="forum-index">
        <ul>
            <li class="header-row">
                <div class="title"><?php echo $this->__('Forum');?></div>
                <div class="last-post"><?php echo $this->__('Last Thread');?></div>
                <div class="threads"><?php echo $this->__('Thread');?></div>
                <div class="posts"><?php echo $this->__('Posts');?></div>
                <div class="clearboth"></div>
            </li>
            <?php foreach(  $man_cat['data'] as $cat):?>
            <li>
                <div class="title">
                    <h2><a href="<?php echo $this->baseurl("/forum/c/{$cat['id']}/" . App::Helper('Utility')->text2normalize($cat['title'])) ?>"><?php echo($cat['title']);?></a></h2>
                    <?php echo($cat['description']); ?>
                </div>
                <div class="last-post"><br /><?php echo App::Component('appForum')->Helper('Data')->Category2LastPostInfo($cat['id']); ?></div>
                <div class="threads"><br /><?php echo App::Component('appForum')->Helper('Data')->Category2ThreadCount($cat['id']); ?></div>
                <div class="posts"><br /><?php echo App::Component('appForum')->Helper('Data')->Category2PostCount($cat['id']); ?></div>
                <div class="clearboth"></div>
            </li>
            <?php endforeach;?>
        </ul>
    </div>
<?php endif;?>
<div class="clearboth"></div>